//package com.yvdedu.my161121.address_book.web.exceptionresolver;
//
//import java.io.IOException;
//
//import org.springframework.validation.BindException;
//import org.springframework.web.servlet.ModelAndView;
//import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//public class BindExceptionResolver extends AbstractHandlerExceptionResolver{
//	private ObjectMapper objectMapper = new ObjectMapper();
//
//    @Override
//    protected ModelAndView doResolveException(HttpServletRequest req, HttpServletResponse resp, Object controller, Exception e) {
//
//
//        try {
//            if (e instanceof BindException) {
//                resp.setContentType("application/json;charset=GBK");
//                resp.getWriter().println(objectMapper.writeValueAsString(new FieldErrResult(((BindException) e).getFieldErrors())));
//                return new ModelAndView();
//            }
//        } catch (JsonProcessingException e1) {
//            e1.printStackTrace();
//
//        } catch (IOException e1) {
//            e1.printStackTrace();
//        }
//
//
//        return null;
//    }
//}
// 
